<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">
    <title>${setting.siteName} - 编辑用户表</title>
    <meta name="keywords" content="${setting.siteName}">
    <meta name="description" content="${setting.siteName}">
    <!-- BEGIN HEADER -->
    [#include "/admin/include/style.ftl"]
    <!-- END HEADER -->
    <style>
        .imgPath {
            display: block;
        }
    </style>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content  animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>编辑用户表</h5>
                    <div class="ibox-tools">
                        <button type="button" class="btn btn-outline btn-white btn-xs" id="btn-return-loippi"
                                onclick="location.href='${base}/admin/t_user/list.jhtml'"><i
                                    class="fa fa-reply-all"></i> 返回列表
                        </button>
                    </div>
                </div>
                <div class="ibox-content">
                    <form id="inputForm" class="form-horizontal" action="${base}/admin/t_user/update.jhtml"
                          method="post">
                        <input type="hidden" value="${tUSER.id}" name="id"/>


                        <!--/row-->
                        <div class="form-group">
                            <div class="row">
                                <div class="col-sm-6">
                                    <label class="col-sm-3 control-label">昵称</label>
                                    <div class="col-sm-9">
                                        <input type="text" name="nickName" class="form-control" maxlength="200"
                                               value="${(tUSER.nickName)!''}"/>
                                    </div>
                                </div>
                                <div class="col-sm-6">
                                    <label class="col-sm-3 control-label">手机号</label>
                                    <div class="col-sm-9">
                                        <input type="text" name="phone" class="form-control" maxlength="200"
                                               value="${(tUSER.phone)!''}"/>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!--/row-->

                        <div class="form-group">
                            <div class="row">
                                <div class="col-sm-6">
                                    <label class="col-sm-3 control-label">启用状态</label>
                                    <div class="col-sm-9">
	                                    <input id="status1" type="radio" name="isEnable" value=1 />禁用
				                              <input id="status2" type="radio" name="isEnable" value=0 />正常
                                    </div>
                                </div>
                                <div class="col-sm-6">
                                    <label class="col-sm-3 control-label">性别</label>
                                    <div class="col-sm-9">
[#--                                        <input type="text" name="gender" class="form-control" maxlength="200"--]
[#--                                               value="${(tUSER.gender)!''}"/>--]
                                         <input type="radio" name="gender" value=1 />女
                                        <input type="radio" name="gender" value=2 />男
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!--/row-->

                        <div class="form-group">
                            <div class="row">
	                            <div class="col-sm-6">
                                    <label class="col-sm-3 control-label">头像</label>
                                    <div class="col-sm-9">
                                        <img id="imgPath" class="imgPath" src="${tUSER.avatar}" />
                                        <input type="file" name="file"  class="form-control upload" onchange="change(this)" maxlength="200"/>
                                        <input type="button"  class="btn btn-warning uploadBtn" value="修改" style="top:100px"/>
                                        <input type="hidden" name="avatar" class="form-control imagePath" maxlength="200" />
                                    </div>
                                </div>
                                <div class="col-sm-6">
                                    <label class="col-sm-3 control-label">用户备注</label>
                                    <div class="col-sm-9">
                                        <input type="text" name="remark" class="form-control" maxlength="200" value="${(tUSER.remark)!''}"/>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!--/row-->

                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-12 col-sm-offset-10">
                                <button type="button" class="btn btn-default" onclick="window.history.back();">返回
                                </button>
                                <button class="btn btn-success" type="submit">保存内容</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- BEGIN Script -->
[#include "/admin/include/script.ftl"]
<!-- END Script -->
<script>
    $(document).ready(function () {
        [@flash_message /]
        $(".chosen-select").chosen({width: "100%"});
        $(".input-daterange").datepicker({keyboardNavigation: false, forceParse: false, autoclose: true});

        $(".browserButton").browser({
            callback: function (url) {
                $("#" + $(this).attr('for')).val(url);
            }
        });
        $(".input-group.date").datepicker({
            todayBtn: "linked",
            keyboardNavigation: false,
            forceParse: false,
            calendarWeeks: true,
            autoclose: true
        });
        $("#inputForm").validate({
                rules: {
                    phone: {
                        required: true
                    },
                    // areaName: {
                    //     required: true
                    // },
                    nickName: {
                        required: true
                    }
                },
                messages: {}
        });
    });

    var isDeletes = document.getElementsByName("isEnable");
    for (var i = 0; i < isDeletes.length; i++) {
        if (isDeletes[i].value == ${tUSER.isEnable}) {
            isDeletes[i].checked = 'checked'
        }
    }

    var sexes = document.getElementsByName("gender");
    for (var i = 0; i < sexes.length; i++) {
        if (sexes[i].value == ${tUSER.gender}) {
            sexes[i].checked = 'checked'
        }
    }

    // 上传图片
    function change(obj) {
        var that = obj;
        var formData = new FormData();
        var fileObj = $(obj)[0].files[0];
        formData.append("file",fileObj);
        $.ajax({
            url:'${base}/admin/file/upload.jhtml',
            type:'POST',
            data:formData,
            dataType: "json",
            async:false,
            processData:false,
            contentType:false,
            success:function(data){
                $(that).parent().find(".imgPath").show();
                $(that).parent().find(".imgPath").attr("src",data.url);
                $(that).parent().find(".uploadBtn").css({"top":"100px"});
                $(that).parent().find(".imagePath").val(data.url);
                $(that).parent().find(".uploadBtn").val("修改");
            }
        })
    }

</script>
</body>
</html>
